VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form frmExcepciones 
   BackColor       =   &H00FFFFFF&
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Excepciones"
   ClientHeight    =   6885
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   7245
   Icon            =   "frmExcepciones.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   6885
   ScaleWidth      =   7245
   Begin VB.Frame Frame1 
      BackColor       =   &H00FFFFFF&
      Height          =   975
      Left            =   120
      TabIndex        =   9
      Top             =   360
      Width           =   6975
      Begin VB.CommandButton cmdVer 
         Appearance      =   0  'Flat
         BackColor       =   &H00FFFFFF&
         Caption         =   "Ver"
         Height          =   315
         Left            =   6000
         MaskColor       =   &H00FFFFFF&
         Style           =   1  'Graphical
         TabIndex        =   1
         Top             =   480
         Width           =   660
      End
      Begin VB.ComboBox cmbProf 
         Appearance      =   0  'Flat
         Height          =   315
         Left            =   120
         Style           =   2  'Dropdown List
         TabIndex        =   0
         Top             =   480
         Width           =   5535
      End
      Begin VB.Label Label2 
         BackColor       =   &H00FFFFFF&
         Caption         =   "Profesional:"
         Height          =   375
         Left            =   120
         TabIndex        =   10
         Top             =   240
         Width           =   1695
      End
   End
   Begin MSComctlLib.ImageList ImageList1 
      Left            =   2280
      Top             =   0
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   16
      ImageHeight     =   16
      MaskColor       =   12632256
      _Version        =   393216
      BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
         NumListImages   =   11
         BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmExcepciones.frx":08CA
            Key             =   ""
         EndProperty
         BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmExcepciones.frx":0E64
            Key             =   ""
         EndProperty
         BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmExcepciones.frx":13FE
            Key             =   ""
         EndProperty
         BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmExcepciones.frx":1998
            Key             =   ""
         EndProperty
         BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmExcepciones.frx":1F32
            Key             =   ""
         EndProperty
         BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmExcepciones.frx":24CC
            Key             =   ""
         EndProperty
         BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmExcepciones.frx":2A66
            Key             =   ""
         EndProperty
         BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmExcepciones.frx":3000
            Key             =   ""
         EndProperty
         BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmExcepciones.frx":359A
            Key             =   ""
         EndProperty
         BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmExcepciones.frx":3B34
            Key             =   ""
         EndProperty
         BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmExcepciones.frx":40CE
            Key             =   ""
         EndProperty
      EndProperty
   End
   Begin VB.Frame Frame2 
      BackColor       =   &H00FFFFFF&
      Caption         =   "Obras Sociales"
      Height          =   5415
      Left            =   120
      TabIndex        =   11
      Top             =   1320
      Width           =   6975
      Begin VB.ListBox lstExcep 
         Enabled         =   0   'False
         Height          =   4740
         Left            =   3840
         Sorted          =   -1  'True
         TabIndex        =   7
         Top             =   480
         Width           =   3015
      End
      Begin VB.CommandButton cmdDelTodas 
         BackColor       =   &H00FFFFFF&
         Caption         =   "<<"
         Enabled         =   0   'False
         Height          =   375
         Left            =   3240
         MaskColor       =   &H00FFFFFF&
         Style           =   1  'Graphical
         TabIndex        =   6
         Top             =   3000
         Width           =   495
      End
      Begin VB.CommandButton cmdAddTodas 
         Appearance      =   0  'Flat
         BackColor       =   &H00FFFFFF&
         Caption         =   ">>"
         Enabled         =   0   'False
         Height          =   375
         Left            =   3240
         MaskColor       =   &H00FFFFFF&
         Style           =   1  'Graphical
         TabIndex        =   3
         Top             =   1560
         Width           =   495
      End
      Begin VB.CommandButton cmdDelUna 
         BackColor       =   &H00FFFFFF&
         Caption         =   "<"
         Enabled         =   0   'False
         Height          =   375
         Left            =   3240
         MaskColor       =   &H00FFFFFF&
         Style           =   1  'Graphical
         TabIndex        =   5
         Top             =   2520
         Width           =   495
      End
      Begin VB.CommandButton cmdAddUna 
         BackColor       =   &H00FFFFFF&
         Caption         =   ">"
         Enabled         =   0   'False
         Height          =   375
         Left            =   3240
         MaskColor       =   &H00FFFFFF&
         Style           =   1  'Graphical
         TabIndex        =   4
         Top             =   2040
         Width           =   495
      End
      Begin VB.ListBox lstTodas 
         Enabled         =   0   'False
         Height          =   4740
         Left            =   120
         Sorted          =   -1  'True
         TabIndex        =   2
         Top             =   480
         Width           =   3015
      End
      Begin VB.Label Label3 
         BackColor       =   &H00FFFFFF&
         Caption         =   "Atiende:"
         Height          =   255
         Left            =   120
         TabIndex        =   13
         Top             =   240
         Width           =   1455
      End
      Begin VB.Label Label1 
         BackColor       =   &H00FFFFFF&
         Caption         =   "Excepciones:"
         Height          =   255
         Left            =   3840
         TabIndex        =   12
         Top             =   240
         Width           =   1815
      End
   End
   Begin MSComctlLib.Toolbar Toolbar1 
      Align           =   1  'Align Top
      Height          =   360
      Left            =   0
      TabIndex        =   8
      Top             =   0
      Width           =   7245
      _ExtentX        =   12779
      _ExtentY        =   635
      ButtonWidth     =   609
      ButtonHeight    =   582
      Appearance      =   1
      Style           =   1
      ImageList       =   "ImageList1"
      _Version        =   393216
      BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
         NumButtons      =   6
         BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Style           =   3
         EndProperty
         BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Enabled         =   0   'False
            Key             =   "Aceptar"
            Object.ToolTipText     =   "Aceptar (F5)"
            ImageIndex      =   5
         EndProperty
         BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Enabled         =   0   'False
            Key             =   "Cancelar"
            Object.ToolTipText     =   "Cancelar (F8)"
            ImageIndex      =   6
         EndProperty
         BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Style           =   3
         EndProperty
         BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "Salir"
            Object.ToolTipText     =   "Salir (Esc)"
            ImageIndex      =   11
         EndProperty
         BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Style           =   3
         EndProperty
      EndProperty
      BorderStyle     =   1
   End
End
Attribute VB_Name = "frmExcepciones"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim con As New ConBaseDatos, i As Integer

Private Sub cmbProf_GotFocus()

cmbProf.BackColor = &HFFFFC0

End Sub

Private Sub cmbProf_KeyPress(KeyAscii As Integer)

Select Case KeyAscii
    Case 13
        SendKeys "{TAB}"
        KeyAscii = 0

    Case 8, 32
        cmbProf.ListIndex = -1

End Select

End Sub

Private Sub cmbProf_LostFocus()

cmbProf.BackColor = &H80000005

End Sub

Private Sub cmdAddTodas_Click()
'agrega todas

For i = 0 To lstTodas.ListCount - 1
    lstTodas.ListIndex = i
    lstExcep.AddItem lstTodas.Text
    lstExcep.ItemData(lstExcep.NewIndex) = lstTodas.ItemData(lstTodas.ListIndex)
    DoEvents
Next i
lstTodas.Clear
lstTodas.Enabled = False
lstExcep.Enabled = True
cmdAddTodas.Enabled = False
cmdAddUna.Enabled = False
cmdDelTodas.Enabled = True
cmdDelUna.Enabled = True

End Sub

Private Sub cmdAddUna_Click()
'agrega una

If lstTodas.ListIndex = -1 Then
    MsgBox "Seleccione obra social", vbCritical, "Error seleccion de datos"
    lstTodas.SetFocus
    Exit Sub
End If

lstExcep.AddItem lstTodas.Text
lstExcep.ItemData(lstExcep.NewIndex) = lstTodas.ItemData(lstTodas.ListIndex)
lstTodas.RemoveItem lstTodas.ListIndex

lstExcep.Enabled = True
cmdDelTodas.Enabled = True
cmdDelUna.Enabled = True

If lstTodas.ListCount = 0 Then
    lstTodas.Enabled = False
    cmdAddTodas.Enabled = False
    cmdAddUna.Enabled = False
End If

End Sub

Private Sub cmdDelTodas_Click()
'quita todas

For i = 0 To lstExcep.ListCount - 1
    lstExcep.ListIndex = i
    lstTodas.AddItem lstExcep.Text
    lstTodas.ItemData(lstTodas.NewIndex) = lstExcep.ItemData(lstExcep.ListIndex)
    DoEvents
Next i
lstExcep.Clear
lstExcep.Enabled = False
lstTodas.Enabled = True
cmdDelTodas.Enabled = False
cmdDelUna.Enabled = False
cmdAddTodas.Enabled = True
cmdAddUna.Enabled = True

End Sub

Private Sub cmdDelUna_Click()
'quita una

If lstExcep.ListIndex = -1 Then
    MsgBox "Seleccione obra social", vbCritical, "Error seleccion de datos"
    lstExcep.SetFocus
    Exit Sub
End If

lstTodas.AddItem lstExcep.Text
lstTodas.ItemData(lstTodas.NewIndex) = lstExcep.ItemData(lstExcep.ListIndex)
lstExcep.RemoveItem lstExcep.ListIndex

lstTodas.Enabled = True
cmdAddTodas.Enabled = True
cmdAddUna.Enabled = True

If lstExcep.ListCount = 0 Then
    lstExcep.Enabled = False
    cmdDelTodas.Enabled = False
    cmdDelUna.Enabled = False
End If

End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)

Select Case KeyCode
    Case 27 'Escape "Salir"
        If Toolbar1.Buttons(5).Enabled Then Toolbar1_ButtonClick Toolbar1.Buttons(5)
        
    Case 112 'F1 "Ayuta"
        frmPrincipal.manual_Click
        
    Case 116 'F5 "Aceptar"
        If Toolbar1.Buttons(2).Enabled Then Toolbar1_ButtonClick Toolbar1.Buttons(2)
    
    Case 119 'F8 "Cancelar"
        If Toolbar1.Buttons(3).Enabled Then Toolbar1_ButtonClick Toolbar1.Buttons(3)
        
End Select

End Sub

Private Sub Form_Load()

Abrir Me

con.AbrirRegistros "select profesional,  apellido + ', ' + nombre + ' - ' + 'Mat.Prof.: ' + matricula_profesional as nombre from profesionales order by apellido,nombre", Consulta
Do While Not con.Registros.EOF
    cmbProf.AddItem DesEditar(con.Registros("nombre"))
    cmbProf.ItemData(cmbProf.NewIndex) = CInt(con.Registros("profesional"))
    con.Registros.MoveNext
    DoEvents
Loop
con.CerrarRegistros

End Sub

Private Sub cmdVer_Click()

If cmbProf.ListIndex = -1 Then
    MsgBox "Seleccione profesional", vbCritical, "Error"
    cmbProf.SetFocus
    Exit Sub
End If

cmbProf.Enabled = False
cmdVer.Enabled = False
Toolbar1.Buttons.Item(2).Enabled = True
Toolbar1.Buttons.Item(3).Enabled = True
Toolbar1.Buttons.Item(5).Enabled = False
CargarExcepciones

End Sub

Private Sub Form_Unload(Cancel As Integer)

If Not Toolbar1.Buttons(5).Enabled Then Cancel = True

End Sub

Private Sub lstExcep_DblClick()

cmdDelUna_Click

End Sub

Private Sub lstExcep_GotFocus()

lstExcep.BackColor = &HFFFFC0

End Sub

Private Sub lstExcep_LostFocus()

lstExcep.BackColor = &H80000005

End Sub

Private Sub lstTodas_DblClick()

cmdAddUna_Click

End Sub

Private Sub lstTodas_GotFocus()

lstTodas.BackColor = &HFFFFC0

End Sub

Private Sub lstTodas_LostFocus()

lstTodas.BackColor = &H80000005

End Sub

Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)

Select Case Button.Key
         
    Case "Salir"
        Unload Me
    
    Case "Aceptar"
        GrabarExcepciones
        Habilitar
                
    Case "Cancelar"
        Habilitar
        
End Select

End Sub

Private Sub Habilitar()

cmbProf.Enabled = True
cmdVer.Enabled = True
Toolbar1.Buttons.Item(2).Enabled = False
Toolbar1.Buttons.Item(3).Enabled = False
Toolbar1.Buttons.Item(5).Enabled = True
cmbProf.ListIndex = -1
lstTodas.Clear
lstExcep.Clear
lstTodas.Enabled = False
lstExcep.Enabled = False
cmdAddTodas.Enabled = False
cmdAddUna.Enabled = False
cmdDelUna.Enabled = False
cmdDelTodas.Enabled = False

End Sub

Private Sub CargarExcepciones()

'todas
lstTodas.Clear
con.AbrirRegistros "select obra_social,nombre from obras_sociales where activo=1 and obra_social not in(select obra_social from excepciones where profesional='" & ReplicarCaracter("0", LargoID, cmbProf.ItemData(cmbProf.ListIndex)) & "') order by nombre", Consulta
Do While Not con.Registros.EOF
    lstTodas.AddItem DesEditar(con.Registros("nombre"))
    lstTodas.ItemData(lstTodas.NewIndex) = CInt(con.Registros("obra_social"))
    con.Registros.MoveNext
    DoEvents
Loop
con.CerrarRegistros
If lstTodas.ListCount > 0 Then
    cmdAddTodas.Enabled = True
    cmdAddUna.Enabled = True
    lstTodas.Enabled = True
End If


'excepciones
lstExcep.Clear
con.AbrirRegistros "select excepciones.obra_social,obras_sociales.nombre from excepciones left join obras_sociales on excepciones.obra_social=obras_sociales.obra_social where excepciones.profesional='" & ReplicarCaracter("0", LargoID, cmbProf.ItemData(cmbProf.ListIndex)) & "' order by obras_sociales.nombre", Consulta
Do While Not con.Registros.EOF
    lstExcep.AddItem DesEditar(con.Registros("nombre"))
    lstExcep.ItemData(lstExcep.NewIndex) = CInt(con.Registros("obra_social"))
    con.Registros.MoveNext
    DoEvents
Loop
con.CerrarRegistros
If lstExcep.ListCount > 0 Then
    cmdDelTodas.Enabled = True
    cmdDelUna.Enabled = True
    lstExcep.Enabled = True
End If


If lstTodas.Enabled Then
    lstTodas.SetFocus
    
ElseIf lstExcep.Enabled Then
    lstExcep.SetFocus
    
End If

End Sub

Private Sub GrabarExcepciones()

con.BorrarRegistros "excepciones", "profesional='" & ReplicarCaracter("0", LargoID, cmbProf.ItemData(cmbProf.ListIndex)) & "'"

For i = 0 To lstExcep.ListCount - 1
    lstExcep.ListIndex = i
    con.InsertarRegistros "excepciones", "profesional,obra_social", "'" & ReplicarCaracter("0", LargoID, cmbProf.ItemData(cmbProf.ListIndex)) & "','" & ReplicarCaracter("0", LargoID, lstExcep.ItemData(lstExcep.ListIndex)) & "'"
    DoEvents
Next i

End Sub
